<?php
include ('header2.php');
 include('databaseconnection.php');
 
$term=$_POST['butt'];
if($_POST['comm'])
{
$c=$_POST['comm'];
$result=mysql_query("SELECT * FROM terms WHERE term='$term'");
while($row=mysql_fetch_array($result))
{
$oldcomm=$row['comments'];
}
$co=$c."</br>".$oldcomm;
mysql_query("UPDATE terms SET comments = '$co' 
WHERE term = '$term'");




echo   "<table width='960px' height='82' border='1' class='table' align='left'>
<tr bgcolor='#FFFFFF'>
<th >Term</th>
<th>Domain</th>
<th>Accepted Meaning</th>
<th>Language</th>



<th>Votes</th>
<th>Comments</th>
<th>Likes</th>
<th>Comments</th>
<th>Add Suggestion</th>
<th></th>

</tr>";
$result=mysql_query("SELECT * FROM terms where term='$term'");
if(!$result) echo "invalid";
while($row=mysql_fetch_array($result))
{

echo "<form action='moredetails.php' method='POST'>";
echo "<tr>";
echo "<td>".$row['term']."</td>";
$term=$row['term'];
echo "<td>".$row['domain']."</td>";
echo "<td>".$row['accepted_meaning']."</td>";
echo "<td>".$row['language']."</td>";


echo "<td>".$row['votes']."</td>";
echo "<td>".$row['comments']."</td>";
echo "<td><a href=''>like</a></td>";
echo "<td><textarea rows='1' cols='9' name='comm'></textarea><input type='submit' name='$term' value='update comment'/><input type='hidden' name='butt' value='$term'</td>";
echo "<td><textarea rows='1' cols='9' name='addsugg'></textarea><input type='submit' name='$term' value='add suggestion'/><input type='hidden' name='butt' value='$term'</td>";
echo "<td><input type='submit' name='$term' value='more'/><input type='hidden' name='butt' value='$term'</td>";


echo "</tr>";
echo "</form>";
}

echo "</table>";            















}
else if($_POST['addsugg'])
{
$suggestion=$_POST['addsugg'];
$result=mysql_query("SELECT * FROM terms WHERE term='$term'");
while($row=mysql_fetch_array($result))
{
$domain=$row['domain'];
$language=$row['language'];
$votes=0;
$comments="";
$suggested_by="Admin";
$suggested_date="2012-02-10";
$status="Pending Review"; 
$query="INSERT INTO suggestions (term, domain, language, suggestion, suggested_by, suggested_date, status,votes,comments) VALUES ('$term', '$domain', '$language', '$suggestion', '$suggested_by', '$suggested_date','$status','$votes','$comments')";
$rez=mysql_query($query);
  if(!$rez) {echo "INvalid".mysql_error();}
  echo   "<table width='960px' height='82' border='1' class='table' align='left'>";
   echo "<tr><td>Your Suggestion is added, to <a href='Suggestion.php'>View</a></td></tr>";
   echo "</table>";
}
}
//echo $term;
else

{

$result=mysql_query("SELECT * FROM terms WHERE term='$term'");
echo   "<table width='960px' height='82' border='1' class='table' align='left'>
<tr bgcolor='#FFFFFF'>
<th></th>

</tr>";
while($row=mysql_fetch_array($result))
{
echo "<form action='moredetails.php' method='POST'>";
echo "<tr>";
echo "<td>Term:</td><td>".$row['term']."</td></tr>";

echo "<tr><td>Domain:</td><td>".$row['domain']."</td></tr>";
echo "<tr><td>Accepted Meaning:</td><td>".$row['accepted_meaning']."</td></tr>";
echo "<tr><td>Language:</td><td>".$row['language']."</td></tr>";
echo "<tr><td>Suggested by:</td><td>".$row['suggested_by']."</td></tr>";
echo "<tr><td>Suggested Date:</td><td>".$row['suggested_date']."</td></tr>";
echo "<tr><td>Checked by:</td><td>".$row['checked_by']."</td></tr>";
echo "<tr><td>Accepted Date:</td><td>".$row['accepted_date']."</td></tr>";
echo "<tr><td>Number of Votes:</td><td>".$row['votes']."</td></tr>";
echo "<tr><td>Comments:</td><td>".$row['comments']."</td></tr>";
echo "<tr><td>Add Comments:</td><td><textarea rows='1' cols='9' name='comm'></textarea><input type='submit' name='$term' value='update comment'/><input type='hidden' name='butt' value='$term'</td></tr>";
echo "<tr><td>Add Suggestion:</td><td><textarea rows='1' cols='9' name='addsugg'></textarea><input type='submit' name='$term' value='Add suggestion'/><input type='hidden' name='butt' value='$term'</td></tr>";
echo "</form>";
//<th>Likes</th>
//<th>Comments</th>
//<th>Add Suggestion</th>


/*echo "<td>".$row['term']."</td>";
echo "<td>".$row['domain']."</td>";
echo "<td>".$row['accepted_meaning']."</td>";
echo "<td>".$row['language']."</td>";
echo "<td>".$row['votes']."</td>";
echo "<td>".$row['comments']."</td>";
echo "<td><a href=''>like</a></td>";
echo "<td><textarea rows='1' cols='9'></textarea></td>";
echo "<td><textarea rows='1' cols='9'></textarea></td>";
echo "<td><a href=''>more</a></td>";

echo "</tr>";*/

}
}
?>